import React, { Component } from 'react';
import PubSub from 'pubsub-js';

export default class Search extends Component {
  componentDidMount() {
    this.getUserData();
  }
  getUserData = async () => {
    try {
      let res = await fetch('/api1/search/users2');
      let data = await res.json();

      PubSub.publish('getUserList', data.items);
    } catch (error) {
      console.log('请求报错', error);
    }
  };

  render() {
    return (
      <section className="jumbotron">
        <h3 className="jumbotron-heading">Search Github Users</h3>
        <div>
          <input type="text" placeholder="enter the name you search" />
          &nbsp;<button>Search</button>
        </div>
      </section>
    );
  }
}
